﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using GeneralDFS.DataEntity.Enum;

namespace GeneralDFS.BusinessLogical.Protocol
{
    public static class ProcessOp
    {
        const string Flag = "|operater|";
        public static Op ReadOp(BinaryReader binaryReader)
        {
            //DateTime begin = DateTime.Now;
            //var readFlag = binaryReader.ReadString();
            //Console.WriteLine("readFlag{0}",(DateTime.Now-begin).TotalSeconds);
            //if (Flag != readFlag)
            //{
            //    throw new Exception("Invaild flag");
            //}
            return (Op)binaryReader.ReadInt32();
        }

        public static void WriteOp(BinaryWriter binaryWriter, Op op)
        {
            if (!binaryWriter.BaseStream.CanWrite) return;
            binaryWriter.Write((int) op);
        }
    }
}
